//
//  StarHomeViewController.m
//  StarPhone
//
//  Created by sxsk on 2025/2/17.
//

#import "StarControlViewController.h"
#import "HomeFirstRowCell.h"
#import "HomeSecondRowCell.h"
#import "HomeThirdRowCell.h"
#import "HomeFourthRowCell.h"
#import "HomeFifthRowCell.h"
#import "HomeSixthRowCell.h"
#import "HomeSeventhRowCell.h"
#import "StarTimerManager.h"
#import "StarControlCell.h"


@interface StarControlViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;



@end

@implementation StarControlViewController

- (BOOL)hideNavigationBar {
    return false;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleString = @"某卫星平台";
    self.titleColor = [UIColor whiteColor];
    self.titleL.font = PingFangSC_Medium(17);
    [self creatNavi];
    [self setUpSubviews];
    

    
}

- (void)setUpSubviews {
    [self.view addSubview:self.tableView];
    [self snapSubviews];
}





#pragma mark - lazy load

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
        _tableView.rowHeight = UITableViewRowAnimationAutomatic;
        _tableView.estimatedRowHeight = 49;
        _tableView.automaticallyAdjustsScrollIndicatorInsets = false;
        //_tableView.contentInset = UIEdgeInsetsMake(-status_height - 20, 0, 20, 0);
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.showsVerticalScrollIndicator = false;
        [self.tableView registerNib:[UINib nibWithNibName:@"HomeFirstRowCell" bundle:nil] forCellReuseIdentifier:@"HomeFirstRowCell"];
        [self.tableView registerNib:[UINib nibWithNibName:@"HomeSecondRowCell" bundle:nil] forCellReuseIdentifier:@"HomeSecondRowCell"];
        [self.tableView registerNib:[UINib nibWithNibName:@"HomeThirdRowCell" bundle:nil] forCellReuseIdentifier:@"HomeThirdRowCell"];
        [self.tableView registerNib:[UINib nibWithNibName:@"HomeFourthRowCell" bundle:nil] forCellReuseIdentifier:@"HomeFourthRowCell"];
        [self.tableView registerNib:[UINib nibWithNibName:@"HomeFifthRowCell" bundle:nil] forCellReuseIdentifier:@"HomeFifthRowCell"];
        [self.tableView registerNib:[UINib nibWithNibName:@"HomeSixthRowCell" bundle:nil] forCellReuseIdentifier:@"HomeSixthRowCell"];
        [self.tableView registerNib:[UINib nibWithNibName:@"HomeSeventhRowCell" bundle:nil] forCellReuseIdentifier:@"HomeSeventhRowCell"];
        [self.tableView registerNib:[UINib nibWithNibName:@"StarControlCell" bundle:nil] forCellReuseIdentifier:@"StarControlCell"];
        
        _tableView.sectionHeaderHeight = 0.5;
        _tableView.sectionFooterHeight = 0.5;
        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];
        _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];
    }
    return _tableView;
}
- (void)snapSubviews {
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.mas_equalTo(top_safeArea);
        make.bottom.inset(0);
    }];
}

#pragma mark - delegate
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.row) {
        case 1:
        {
            HomeFirstRowCell * cell = [tableView dequeueReusableCellWithIdentifier:@"HomeFirstRowCell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.backgroundColor = [UIColor clearColor];
            cell.contentView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
            return cell;
        }
            break;
        case 0:
        {
            HomeSecondRowCell * cell = [tableView dequeueReusableCellWithIdentifier:@"HomeSecondRowCell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.backgroundColor = [UIColor clearColor];
            cell.contentView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
            
            return cell;
        }
            break;
        case 2:
        {
            HomeThirdRowCell * cell = [tableView dequeueReusableCellWithIdentifier:@"HomeThirdRowCell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.backgroundColor = [UIColor clearColor];
            cell.contentView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
            return cell;
        }
            break;
        case 3:
        {
            HomeFourthRowCell * cell = [tableView dequeueReusableCellWithIdentifier:@"HomeFourthRowCell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.backgroundColor = [UIColor clearColor];
            cell.contentView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
            return cell;
        }
            break;
        case 4:
        {
            StarControlCell * cell = [tableView dequeueReusableCellWithIdentifier:@"StarControlCell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.backgroundColor = [UIColor clearColor];
            cell.contentView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
            return cell;
        }
            break;
        default:
        {
            HomeFirstRowCell * cell = [tableView dequeueReusableCellWithIdentifier:@"HomeFirstRowCell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.contentView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
            return cell;
            
        }
            break;
    }
}

- (void)dealloc
{
    [[StarTimerManager sharedInstance] deinit];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.row) {
        case 0:
           return HEIGHT_PRO(32);
        case 1:
            return HEIGHT_PRO(95);
        case 2:
            return HEIGHT_PRO(70);
        case 3:
            return HEIGHT_PRO(104);
        case 4:
            return HEIGHT_PRO(248);
        default:
            return HEIGHT_PRO(32);
            break;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.05;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = kF5F5F5;
    return view;
}


@end
